package com.booking.springrestful.controller;

import com.booking.springrestful.domain.Consultationroom;
import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.ConsultationroomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/room")
public class roomController {

    @Resource
    private ConsultationroomService roomService;


    @PostMapping("/add")
    private ResponseResult addRoom(@RequestBody Consultationroom room){
        Integer id = roomService.addRoom(room);
        return ResponseResult.success("新增成功",id.toString());
    }


    @PostMapping("/update")
    private ResponseResult updateRoom(@RequestBody Consultationroom room){
        roomService.updateRoom(room);
        return ResponseResult.success("修改成功");
    }


    @PostMapping("/delete")
    private ResponseResult deleteRoom(@RequestBody Consultationroom room){
        roomService.deleteRoom(room);
        return ResponseResult.success("删除成功");
    }


    @GetMapping("/get")
    private ResponseResult<List<Consultationroom>> getRoom(){
        List<Consultationroom> list=roomService.getRoom();
        return ResponseResult.success(list);
    }

    @PostMapping("/deleteAll")
    private ResponseResult deleteAll(@RequestBody List<Consultationroom> list){
        roomService.deleteAll(list);
        return ResponseResult.success("删除成功");
    }

}
